home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr47 / alt_lan.zip / PARASOL.ASC < prev    next >
Text File  |  1993-09-17  |  2KB  |  178 lines

  1. _THE PARASOL PROGRAMMING LANGUAGE_
  2. by Bob Jervis
  3.  
  4. [LISTING ONE]
  5.  
  6. // O1 is an object with class type.  
  7. //  The type of O1 is anonymous.
  8.  
  9. O1: {
  10.     hidden: int;
  11.  
  12.     public:
  13.     record: (i: int) =
  14.         {
  15.         hidden = i;
  16.         }
  17.     func:   (i: int) int =
  18.         {
  19.         return i * 3 + hidden;
  20.         }
  21.     };
  22. main:   entry   () = {
  23.     x:  int;
  24.     O1 record(3);
  25.     x = O1 func(5);         // Method call
  26.     printf("Value is %d\n", x); // Prints 'Value is 18'
  27.     }
  28.  
  29.  
  30. [LISTING TWO]
  31.  
  32. include math;
  33. point:  type    {
  34.     x, y:   short;
  35.     hypot:  () single =
  36.         {
  37.         f, g: short;
  38.         f = x;
  39.         g = y;
  40.         return sqrt(f * f + g * g);
  41.         }
  42.  
  43.  
  44. [LISTING THREE]
  45.  
  46. window: type    { public:
  47.     redraw: dynamic () = { ... }
  48.     };
  49. editor: type    inherit window { public:
  50.     redraw: dynamic () = 
  51.         {
  52.         super redraw();
  53.          ...
  54.         }
  55.     };
  56. func:   (p: ref window) =
  57.     {
  58.     p redraw();
  59.     }
  60.  
  61.  
  62.  
  63. Example 1:
  64.  
  65. (a)
  66.  
  67. name: exposure type-declaration = initializer;
  68.  
  69.  
  70. (b)
  71.  
  72. name: exposure type-declaration = { statements; }   
  73.  
  74.  
  75. (c)
  76.  
  77. name: exposure type type-declaration;           
  78.  
  79.  
  80. (d)
  81.  
  82. i, j, k: int;
  83.  
  84.  
  85. (e)
  86.  
  87. i:  int;
  88. i = 7;
  89.  
  90.  
  91. (f)
  92.  
  93. i = 7;
  94. i:  int;
  95.  
  96.  
  97.  
  98. Example 2:
  99.  
  100. (a)
  101.  
  102. i:  public  int;
  103.  
  104.  
  105. (b)
  106.  
  107. byte:       public  type    unsigned[8];
  108. short:      public  type    signed[16];
  109. int:        public  type    signed[32];
  110. long:       public  type    signed[64];
  111.  
  112. single: public  type    float[32];
  113. double: public  type    float[64];
  114. extended:   public  type    float[80];
  115.  
  116.  
  117. (c)
  118.  
  119. abs:    (x: int) int = {
  120.     return x >= 0 ? x : -x;
  121.     }
  122.  
  123.  
  124. (d)
  125.  
  126. buffer: [512] byte;
  127.  
  128.  
  129. (e)
  130.  
  131.  
  132. x: ref () ref [10] single;
  133.  
  134.  
  135.  
  136. Example 3:
  137.  
  138. (a)
  139.  
  140. class-modifiers {
  141. declarations;
  142. }
  143.  
  144.  
  145. (b)
  146.  
  147. point: type    { public:
  148.     x, y:   short;
  149.     };
  150.  
  151.  
  152. (c)
  153.  
  154. object   method ( arguments );
  155.  
  156.  
  157. Example 4:
  158.  
  159. (a)
  160. Unit a:
  161.   xyz: public  int;
  162. Unit b:
  163.   include a;
  164.   ... xyz ...
  165.  
  166.  
  167. (b)
  168.  
  169. Unit aa:
  170.   xyz: public int;
  171. Unit bb:
  172.   xyz: public double;
  173. Unit cc:
  174.   include aa, bb;
  175.   ... aa::xyz ... 
  176.   ... bb::xyz ...
  177.  
  178.